Getting checked items from listView

This may have been answered already, but I haven't been able to find the solution.  I have a listView with Checkboxes and Multiselect set.  I then have a button that, for now, gives a certain message if you've selected 2 or more items in the listView.  When I check 2 of the choices in the list and click the button, I'm getting the message "Please select 2 or more items" instead of the correct message which should be "The user has selected AT LEAST 2 items from the listView!"  Here is a sample of my code:

void doExport(DB db) {
    string s = "";
    int numSelected = 0;
    
    //First make sure at least 2 items are selected
    for s in dbeBaselineSelect do {
        infoBox(s);
        numSelected++;
    }
    if (numSelected >= 2) {
        infoBox("User as selected AT LEAST 2 items from the listView!");
    } else {
        infoBox("Please select at least 2 baselines to compare.")
    }
}
void buildDialog() {
    dbMain = create(SCRIPT_NAME, styleCentered|styleFixed);
    apply(dbMain, "Compare", doExport);
    
    dbeBaselineFrame = frame(dbMain, "Select Baselines to compare", 360, 310);
    dbeBaselineFrame->"top"->"inside"->dbeFrame;
    dbeBaselineFrame->"left"->"inside"->dbeFrame;
    dbeBaselineFrame->"right"->"unattached";
    dbeBaselineFrame->"bottom"->"unattached";
    
    dbeBaselineSelect = listView(dbMain, listViewOptionCheckboxes|listViewOptionMultiselect, 340, 14, dummy);
    dbeBaselineSelect->"top"->"inside"->dbeBaselineFrame;
    dbeBaselineSelect->"left"->"inside"->dbeBaselineFrame;
    dbeBaselineSelect->"right"->"unattached";
    dbeBaselineSelect->"bottom"->"unattached";
    
    realize(dbMain);
}

I've figured out that the problem is that the items aren't highlighted as being selected, but how do I get the list of checkboxes that have been selected instead?

 

Chris


chrscote - Mon Mar 05 14:41:41 EST 2018

Re: Getting checked items from listView
PekkaMakinen - Tue Mar 06 01:51:10 EST 2018

getCheck 
Declaration 
bool getCheck(DBE listView, int index) 
Operation 
Returns true if the check box identified by index is selected; otherwise, returns false. This works only for list views. 

Re: Getting checked items from listView
chrscote - Tue Mar 06 11:06:08 EST 2018

PekkaMakinen - Tue Mar 06 01:51:10 EST 2018

getCheck 
Declaration 
bool getCheck(DBE listView, int index) 
Operation 
Returns true if the check box identified by index is selected; otherwise, returns false. This works only for list views. 

Thanks Pekka.  I had forgotten about that function.